package com.itheima.ClassTest;

import java.util.Scanner;

public class test4 {
    public static void main(String[] args) {
        String userName ="admin";
        String passWord = "123456";
        Scanner sc = new Scanner(System.in);
        for (int i = 1; i <=3; i++) {
            System.out.println("请输入用户名:");
            String scName = sc.nextLine();
            System.out.println("请输入密码:");
            String scPassword = sc.nextLine();
            if(scName.equals(userName)&&scPassword.equals(passWord)){
                System.out.println("登录成功!");
                break;
            }else{
                if(i==3){
                    System.out.println("对不起!您输入的次数已超过上限!");
                }else{
                    System.out.println("用户名或密码有误!还剩"+(3-i)+"次机会~");
                }
            }
        }
    }
}
